﻿CREATE PROCEDURE [dbo].[books_delete]
@bookId int

AS
-- remove all authors
delete from BooksByAuthor
where BooksByAuthor.BookId =@bookId;
-- remove all categories
delete from BooksByCategory
where BooksByCategory.BookId =@bookId;
-- remove all Responses

delete from Responses
where Responses.BookId=@bookId;

DELETE FROM [dbo].Favorites
WHERE Favorites.BookId = @bookId

DELETE FROM [dbo].[Ratings]
WHERE Ratings.BookId = @bookId

DELETE FROM [dbo].[Books]
WHERE
    Books.[BookId]=@bookId

RETURN 0
